﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Server
{
    class AccountDAO : DataProvider
    {
        public bool testAccount(string UserName, string Pass)
        {
            connect();
            string sqlString = "Select * from Account where UserName = '" + UserName + "' and Password = '" + Pass + "'";
            object result = executeScalar(sqlString);
            if (result == null)
                return false;
            return true;
        }

        public bool registerAccount(string UserName, string Pass)
        {
            connect();
            string sqlString = "Select * from Account where UserName = '" + UserName  + "'";
            object result = executeScalar(sqlString);
            if (result != null)
                return false;//user name exists
            sqlString = "Insert into Account values('" + UserName + "', '" + Pass + "')";
            executeNonQuery(sqlString);
            return true;
        }
    }
}
